import java.util.Arrays;

public class Solution1288 {
    public int removeCoveredIntervals(int[][] intervals) {
        Arrays.sort(intervals,(a,b)-> a[0]-b[0]==0?b[1]-a[1]:a[0]-b[0]);
        int ans=0,r=-1;
        for (int[] interval : intervals) {
            if (interval[1]<=r){
                ans++;
            }
            r=Math.max(r,interval[1]);
        }
        return intervals.length-ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1288().removeCoveredIntervals(new int[][]{{1,4},{3,6},{2,8}}));
    }
}
